package com.qianxun.module.datasource1.admin.rest;

import com.qianxun.module.datasource1.admin.service.SysDataModifyLockService;
import com.qianxun.module.datasource1.admin.service.SysUserFunctionRoleRelationService;
import com.qianxun.module.datasource1.admin.util.SysUserUtil;
import com.qianxun.module.base.constant.Result;
import com.qianxun.module.base.bo.ValidGroup;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

/**
* com.zch.admin.base.entity.SysAdminFnroleUserRelation模型http接口处理
*
* @author: admin
* @date: 2019-11-28
* @version: 1.0.0
*/
@Validated(value = {ValidGroup.All.class})
@RestController
@RequestMapping(value="/admin/userFunctionRoleRelation" ,produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
public class SysUserFunctionRoleRelationRestController {

    @Resource
    private SysUserFunctionRoleRelationService baseService;
    @Resource
    private SysDataModifyLockService sysDataModifyLockService;

    @RequestMapping(value = {"/setAuthority/{userUuid}"})
    public Result setAuthority(@PathVariable(value = "userUuid")String userUuid ,@RequestParam("userId") Long userId , @RequestParam(value = "fnRoleIds") Integer[] fnRoleIds ){
        sysDataModifyLockService.checkLocked(SysUserUtil.dataLockKey(userId));

        baseService.setAuthority(userUuid ,fnRoleIds);
        return Result.success();
    }
}
